﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    enum npcname
    {
        刘备 = 1,
        孙权,
        曹操
    }
    enum fist
    {
        剪刀 = 1,
        石头,
        布
    }
    class Program
    {

        static void Main(string[] args)
        {
            int pgroud = 0;
            int ngroud = 0;
            int session = 0;
            against(ref pgroud, ref ngroud, ref session);
            against2(ref pgroud, ref ngroud, ref session);
        }
        public static void against2(ref int pgroud, ref int ngroud, ref int session)
        {
            Console.WriteLine("要开始下一局吗？1、要 2、 不要");
            int choose3 = int.Parse(Console.ReadLine());
            switch (choose3)
            {
                case 1:
                    against(ref pgroud, ref ngroud, ref session);
                    against2(ref pgroud, ref ngroud, ref session);
                    break;
                case 2:
                    Console.WriteLine("拜了个拜");
                    break;
                default:
                    Console.WriteLine("输入错误,重新开始");
                    against(ref pgroud, ref ngroud, ref session);
                    break;
            }
        }
        public static void against(ref int pgroud, ref int ngroud, ref int session)
        {
            Console.WriteLine("----游戏即将开始----");
            Console.WriteLine("--------------------");
            Console.WriteLine("-----猜拳·开始-----");
            Console.WriteLine("--------------------");
            Console.WriteLine("出拳规则：1、剪刀 2、 石头 3、 布");
            Console.WriteLine("请选择对方角色：1、刘备 2 、孙权 3、 曹操  (请输入相应数字)");
            int choose1 = int.Parse(Console.ReadLine());
            npcname f = (npcname)choose1;

            Console.WriteLine("请输入您的名字");
            string play = Console.ReadLine();
            player player = new player(play);
            game(ref f, ref pgroud, ref ngroud, ref session, ref player);

        }

        public static void game(ref npcname f, ref int pgroud, ref int ngroud, ref int session, ref player player)
        {
            NPC npc = new NPC(f.ToString());
            int a = player.fist();
            fist playfist = (fist)a;
            int b = npc.fist();
            fist npcfist = (fist)b;
            Console.WriteLine("{0}出的拳为{1}", player.Name, playfist);
            Console.WriteLine("{0}出的拳为{1}", npc.Name, npcfist);
            string a1 = playfist.ToString();
            string a2 = npcfist.ToString();
            judge(a1, a2, ref pgroud, ref ngroud, ref session);
            Console.WriteLine("是否开始下一轮 1、继续 2 、停止 ");
            int choose = int.Parse(Console.ReadLine());
            switch (choose)
            {
                case 1:
                    game(ref f, ref pgroud, ref ngroud, ref session, ref player);
                    break;
                case 2:
                    Console.WriteLine("{0}对阵{1}", player.Name, npc.Name);
                    Console.WriteLine("对阵次数{0}", session);
                    Console.WriteLine("姓名     得分");
                    Console.WriteLine("{0}      {1}", player.Name, pgroud);
                    Console.WriteLine("{0}      {1}", npc.Name, ngroud);
                    break;
                default:
                    Console.WriteLine("输入错误,重新开始");
                    game(ref f, ref pgroud, ref ngroud, ref session, ref player);
                    break;
            }
        }

        public static void judge(string player, string npcfist, ref int pgroud, ref int ngroud, ref int session)
        {
            if (player.Equals("石头") && npcfist.Equals("剪刀") || player.Equals("剪刀") && npcfist.Equals("布") || player.Equals("布") && npcfist.Equals("石头"))
            {
                Console.WriteLine("你获得胜利");
                pgroud++;
                session++;
            }
            else if (player.Equals(npcfist))
            {
                Console.WriteLine("平局了");
                session++;
            }
            else
            {
                Console.WriteLine("你输了");
                ngroud++;
                session++;
            }
        }
    }
}
